//
// Created by 1065246 on 2023/11/17.
//
#include<stdio.h>
#include<malloc.h>
#include<string.h>

typedef struct {
    int top;
    int bottom;
    char data[100];
} stack;

stack *initStack() {
    stack *stk = malloc(sizeof(stack));
    if (stk == NULL) {
        return 0;
    }
    stk->top = 0;
    stk->bottom = 0;
    return stk;
}

void inStack(stack *stk, char data) {
    stk->data[stk->top] = data;
    stk->top++;
}

char outStack(stack *stk) {
    if (stk->top != stk->bottom) {
        char str = stk->data[stk->top - 1];
        stk->top--;
        return str;
    }
}

void foreachStack(stack *stk) {
    while (stk->top != stk->bottom) {
        char str = stk->data[stk->top];
        stk->top--;
        printf("%c", str);
    }
}

